undefined method `model_name' for NilClass:Class - Rails application
        Posted  
        
            by 
                user1270259
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user1270259
        
        
        
        Published on 2012-09-05T15:36:28Z
        Indexed on 
            2012/09/05
            15:37 UTC
        
        
        Read the original article
        Hit count: 196
        
So I have seen other articles here on stack about this and a lot of the time people are not doing @post = post.new. I read some where to use the plural...??
any ways I am getting this error on my discussion code:
Discussion Controller
class DiscussionsController < ApplicationController
  def index
    @discussion = Discussion.new
    @discussions = Discussion.all
  end
  def create
    @discussion = Discussion.create(params[:discussion])
    if @discussion.save
      redirect_to tasks_path, :flash => {:success => 'Created a new discussion'}
    else
      redirect_to tasks_path, :flash => {:error => 'Failed to create a discussion'}
    end
  end
end
Discussion Form
<%= form_for @discussion do |f| %>
    <p><%= f.label :title %>
    <%= f.text_field :title %></p>
    <p><%= f.label :content %>
    <%= f.text_area :content %></p>
<% end %>
Discussion Routes
  resources :discussions do
    resources :comments
  end
Now as far as I know I am doing this right, because I have a task form set up essentially the same way - but I have looked at my code for hours and have googled and tried other examples and now i see this:
undefined method `model_name' for NilClass:Class
Extracted source (around line #1):
1: <%= form_for @discussion do |f| %>
2: 
3:  <p><%= f.label :title %>
4:  <%= f.text_field :title %></p>
Which should mean that I am missing something from my controller.....is it as asilly as a spelling mistake? >.>
© Stack Overflow or respective owner